//
//  MBLoginDataManager.m
//  Meboo
//
//  Created by kyo on 2023/10/8.
//

#import "MBLoginDataManager.h"
#import "MBHTTPNetworking.h"
@implementation MBLoginDataManager
+ (MBLoginDataManager *)sharedManager {
    static dispatch_once_t onceToken;
    static MBLoginDataManager *obj;
    dispatch_once(&onceToken, ^{
        obj = [[self alloc] init];
    });
    return obj;
}

#pragma mark -登录
- (void)loginWithIdentityTokenStr:(NSString *)identityTokenStr userName:(NSString *)userName email:(NSString *)email success:(void(^)(BOOL success))resultBlock {
    if (email.length == 0) {
        email = @"";
    }
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:@4 forKey:@"loginType"];
    [params setObject:userName forKey:@"userName"];
    [params setObject:identityTokenStr forKey:@"account"];
    [params setObject:email forKey:@"email"];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/auth/login" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSLog(@"");
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            MBUserAccount  *account = [MBUserAccount new];
            account.chatUserId = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"userCode"]];
            account.avatarUrl = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"avatarUrl"]];
            account.nickName = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"nickName"]];
            account.userFlag = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"newUserFlag"]];
            account.token = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"token"]];
            NSString *isUserValidStr = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"isUserValid"]];
            if ([isUserValidStr isEqualToString:@"1"]) {
                account.isUserValid = YES;
            } else {
                account.isUserValid = NO;
                [MBUserAccount  saveAccount:account];
                [self registerUserInfoSuccess:^(BOOL success) {
                    if (resultBlock) resultBlock(success);
                }];
            }
            NSString *userTypeStr = [[NSUserDefaults standardUserDefaults]valueForKey:@"meboo_appflyer_usertype"];
        if ([userTypeStr isEqualToString:@"Organic"] || userTypeStr.length == 0) {
            account.isUserType = NO;
        } else {
            account.isUserType = YES;
        }
            
            [MBUserAccount  saveAccount:account];
            
            if ([isUserValidStr isEqualToString:@"1"]) {
                //只有注册过的 才能获取用户信息,否则会报错
                [self getUserInfoWithCode:@"" success:^(BOOL success) {
                    
                }];
            }
            if ([isUserValidStr isEqualToString:@"1"]) {
                if (resultBlock) resultBlock(YES);
            }
//            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

#pragma mark -注册
- (void)registerUserInfoSuccess:(void(^)(BOOL success))resultBlock {
    /**
     埋点 code
     注册 100
     */
    [[NSIOApiManager sharedManager] setIOWithCode:@"100" content:@"REGISTER"];
    MBUserAccount *acount = [MBUserAccount defaultAccount];
    acount.nickName = [self getTimeNow];
    acount.gender = @"1";
    acount.lookingFor = @"2";
    acount.birthday = [self get18BirthDayStr];
    acount.images = [NSMutableArray arrayWithArray:@[@"/mebooRegisterDefult/RegisterPhotoMebooDefult.jpg"]];
    acount.avatarUrl = @"/mebooRegisterDefult/RegisterPhotoMebooDefult.jpg";
    acount.socialConnections = @"Making new friends";
    [MBUserAccount saveAccount:acount];
    [self getLookingForValue];
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:[MBUserAccount defaultAccount].nickName forKey:@"nickName"];
    [params setObject:[MBUserAccount defaultAccount].gender forKey:@"gender"];
    [params setObject:[MBUserAccount defaultAccount].lookingFor forKey:@"lookingFor"];
    [params setObject:[MBUserAccount defaultAccount].birthday forKey:@"birthday"];
    [params setObject:[MBUserAccount defaultAccount].aboutMe forKey:@"aboutMe"];
    [params setObject:[MBUserAccount defaultAccount].interests ?: [NSMutableArray array] forKey:@"interests"];
    [params setObject:[MBUserAccount defaultAccount].images ?: [NSMutableArray array] forKey:@"images"];
    [params setObject:[MBUserAccount defaultAccount].avatarUrl forKey:@"avatarUrl"];
    [params setObject:[MBUserAccount defaultAccount].socialConnections forKey:@"socialConnections"];
    
    [params setObject:[self getAcceptValue] forKey:@"youAccept"];
    [params setObject:[self getWantValue] forKey:@"userWant"];
    
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/users/initUserInfo" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            MBUserAccount  *account = [MBUserAccount defaultAccount];
            account.isUserValid = YES;
            [MBUserAccount  saveAccount:account];
            [self getUserInfoWithCode:@"" success:^(BOOL success) {
                
            }];
            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

#pragma mark -获取协议链接  *********此接口暂时不用,url写死的
- (void)getAgreementUrl:(void(^)(BOOL success))resultBlock {
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:@2 forKey:@"code"];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/app/configs" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSLog(@"");
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            NSString *paymentAgreement = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"paymentAgreement"]];
            NSString *privacyPolicy = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"privacyPolicy"]];
            NSString *terms = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"terms"]];
            //暂存
            [[NSUserDefaults standardUserDefaults] setObject:privacyPolicy forKey:@"MB_Agreement_Url_privacyPolicy"];
            [[NSUserDefaults standardUserDefaults] setObject:terms forKey:@"MB_Agreement_Url_terms"];
            [[NSUserDefaults standardUserDefaults] setObject:paymentAgreement forKey:@"MB_Agreement_Url_paymentAgreement"];
            [[NSUserDefaults standardUserDefaults] synchronize];
            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

#pragma mark -获取用户信息
- (void)getUserInfo:(void(^)(BOOL success))resultBlock {
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/users/userInfo" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSLog(@"");
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            NSString *iconStr = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"avatarUrl"]];
            MBUserAccount  *account = [MBUserAccount defaultAccount];
            if (![self isEmpty:iconStr]) {
                account.avatarUrl = iconStr;
            } else {
                account.avatarUrl = @"";
            }
            
            account.nickName = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"nickName"]];
            account.age = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"age"]];
//            account.avatarUrl = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"avatarUrl"]];
            account.gender = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"gender"]];
            account.aboutMe = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"aboutMe"]];
            if ([self isEmpty:account.aboutMe]) {
                account.aboutMe = @"";
            }
            account.lookingFor = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"lookingFor"]];
            account.socialConnections = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"socialConnections"]];
            account.birthday = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"birthday"]];
            
            
            NSArray *images = responseObject[@"data"][@"images"];
            if (![self isEmpty:images]) {
                account.images = [NSMutableArray arrayWithArray:images];
            }
            
            [MBUserAccount  saveAccount:account];
            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

#pragma mark -更改个人信息
- (void)changeUserInfoWithKey:(NSString *)key value:(id)value Success:(void(^)(BOOL success))resultBlock {
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:value forKey:key];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/users/changeUserInfo" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

#pragma mark -获取升级信息信息
- (void)checkVersion:(void(^)(BOOL success))resultBlock {
    __WeakSelf
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] forKey:@"appCode"];
    [params setObject:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] forKey:@"versionCode"];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/app/upgradation" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            if ([responseObject[@"data"][@"updateFlag"] boolValue]) {
                weakSelf.versionDict = responseObject[@"data"];
                if (resultBlock) resultBlock(YES);
            } else {
                if (resultBlock) resultBlock(NO);
            }
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

#pragma mark -获取验证码
- (void)getPhoneCodeWithPhone:(NSString *)phone success:(void(^)(BOOL success))resultBlock {
//    __WeakSelf
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:phone forKey:@"phone"];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/sms/sendSMS" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

#pragma mark -验证码登录
- (void)loginWithPhone:(NSString *)phone code:(NSString *)code userID:(NSString *)userID success:(void(^)(BOOL success))resultBlock {
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:[NSString stringWithFormat:@"+1%@",phone] forKey:@"mobile"];
    [params setObject:userID forKey:@"account"];
    [params setObject:@1 forKey:@"loginType"];
//    [params setObject:code forKey:@"verificationCode"];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/auth/login" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            
            MBUserAccount  *account = [MBUserAccount new];
            account.chatUserId = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"userCode"]];
            account.avatarUrl = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"avatarUrl"]];
            account.nickName = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"nickName"]];
            account.userFlag = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"newUserFlag"]];
            account.token = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"token"]];
            NSString *isUserValidStr = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"isUserValid"]];
            if ([isUserValidStr isEqualToString:@"1"]) {
                account.isUserValid = YES;
            } else {
                account.isUserValid = NO;
                [MBUserAccount  saveAccount:account];
                [self registerUserInfoSuccess:^(BOOL success) {
                    if (resultBlock) resultBlock(success);
                }];
            }

                NSString *userTypeStr = [[NSUserDefaults standardUserDefaults]valueForKey:@"meboo_appflyer_usertype"];
            if ([userTypeStr isEqualToString:@"Organic"] || userTypeStr.length == 0) {
                account.isUserType = NO;
            } else {
                account.isUserType = YES;
            }
            [MBUserAccount  saveAccount:account];
            
            
            if ([isUserValidStr isEqualToString:@"1"]) {
                //只有注册过的 才能获取用户信息,否则会报错
                [self getUserInfoWithCode:@"" success:^(BOOL success) {
                    
                }];
            }
            
            if ([isUserValidStr isEqualToString:@"1"]) {
                if (resultBlock) resultBlock(YES);
            }
//            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

- (void)getAppsFlyersStateWithUid:(NSString *)uid success:(void(^)(BOOL success))resultBlock {
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:[NSString stringWithFormat:@"https://gcdsdk.appsflyer.com/install_data/v4.0/id6471480825?devkey=GRYmCbW2mUt5Qitw6v4AVc&device_id=%@",uid] method:@"GET" parameters:params success:^(id  _Nullable responseObject) {
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            NSString *state = [NSString stringWithFormat:@"%@",responseObject[@"af_status"]];
            //暂存
            [[NSUserDefaults standardUserDefaults] setObject:state forKey:@"meboo_appflyer_usertype"];
            [[NSUserDefaults standardUserDefaults] synchronize];
            
            MBUserAccount *account = [MBUserAccount defaultAccount];
        if ([state isEqualToString:@"Organic"] || state.length == 0) {
            account.isUserType = NO;
        } else {
            account.isUserType = YES;
            if (account.isNewHome == 1) {
                //强制切换  数据请求结果可能晚于home加载,此时应该强制切换过去
                AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
                appDelegate.window.rootViewController = [[BaseTabBarViewController alloc]init];
            }
        }
            //debugTest 测试自然流量/非自然流量 正式需注释
//            [MBProgressHUD showWarnMessage:state];
            [MBUserAccount saveAccount:account];
            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

#pragma mark -获取用户信息
- (void)getUserInfoWithCode:(NSString *)userCode success:(void(^)(BOOL success))resultBlock {
    if (userCode.length == 0) {
        userCode = @"";
    }
    self.userInfoModel = [NSUserInfoModel new];
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    [params setObject:userCode forKey:@"userCode"];
    [[MBHTTPNetworking sharedInstance] WSAFNoOAuthUrlString:@"api/users/userInfo" method:@"POST" parameters:params success:^(id  _Nullable responseObject) {
        NSLog(@"");
        NSInteger code = [responseObject[@"code"] integerValue];
        if (code == 0) {
            if (userCode.length > 0) {
                self.userInfoModel = [NSUserInfoModel mj_objectWithKeyValues:responseObject[@"data"]];
            } else {
                NSString *iconStr = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"avatarUrl"]];
                MBUserAccount  *account = [MBUserAccount defaultAccount];
                if (![self isEmpty:iconStr]) {
                    account.avatarUrl = iconStr;
                } else {
                    account.avatarUrl = @"";
                }
                
                account.nickName = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"nickName"]];
                account.age = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"age"]];
    //            account.avatarUrl = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"avatarUrl"]];
                account.gender = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"gender"]];
                account.aboutMe = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"aboutMe"]];
                if ([self isEmpty:account.aboutMe]) {
                    account.aboutMe = @"";
                }
                account.lookingFor = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"lookingFor"]];
                if ([self isEmpty:account.lookingFor]) {
                    account.lookingFor = @"";
                }

                account.socialConnections = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"socialConnections"]];
                account.birthday = [NSString stringWithFormat:@"%@",responseObject[@"data"][@"birthday"]];
                
                
                NSArray *images = responseObject[@"data"][@"images"];
                if (![self isEmpty:images]) {
                    account.images = [NSMutableArray arrayWithArray:images];
                }
                
                NSArray *interests = [NSArray array];
                if (![self isEmpty:responseObject[@"data"][@"interests"]]) {
                    interests = responseObject[@"data"][@"interests"];
                }
                account.interests = [NSMutableArray arrayWithArray:interests];
                
                NSArray *youAccept = [NSArray array];
                if (![self isEmpty:responseObject[@"data"][@"youAccept"]]) {
                    youAccept = responseObject[@"data"][@"youAccept"];
                }
                account.youAccept = [NSMutableArray arrayWithArray:youAccept];
                
                NSArray *userWant = [NSArray array];
                if (![self isEmpty:responseObject[@"data"][@"userWant"]]) {
                    userWant = responseObject[@"data"][@"userWant"];
                }
                account.userWant = [NSMutableArray arrayWithArray:userWant];
                

                account.isVip = [responseObject[@"data"][@"isMember"] boolValue];
                account.vipDateStr = responseObject[@"data"][@"expiryDate"];
                [MBUserAccount  saveAccount:account];
            }
            if (resultBlock) resultBlock(YES);
        } else {
            if (resultBlock) resultBlock(NO);
        }
    } failure:^(NSError * _Nullable error) {
        if (resultBlock) resultBlock(NO);
    }];
}

- (BOOL)isEmpty:(id)object {
    
    if(object == nil || [object isKindOfClass:[NSNull class]])
    {
        return YES;
    }
    
    if([object isKindOfClass:[NSDictionary class]])
    {
        NSDictionary *empty = (NSDictionary*)object;
        if (empty.allKeys == 0) {
            return YES;
        }
    }
    else if([object isKindOfClass:[NSArray class]])
    {
        NSArray *empty = (NSArray*)object;
        if (empty.count == 0){
            return YES;
        }
    }
    else if ([object isKindOfClass:[NSString class]])
    {
        if([(NSString *)object isEqualToString:@""] || [(NSString *)object isEqualToString:@"<null>"])
            return YES;
    }
    else if ([object isKindOfClass:[NSNumber class]])
    {
        if (object == 0) {
            return YES;
        }
        
    }
    else if ([object isKindOfClass:[NSSet class]])
    {
        NSSet *empty = (NSSet*)object;
        if (empty.count == 0){
            return YES;
        }
    }
    
    return NO;
}

- (NSString *)getTimeNow {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ;
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    
    //设置时区,这个对于时间的处理有时很重要
    
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
    
    [formatter setTimeZone:timeZone];
    
    NSDate *datenow = [NSDate date];//现在时间,你可以输出来看下是什么格式
    
    NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)[datenow timeIntervalSince1970]*1000];
    
    int randomNumber = arc4random_uniform(9000) + 1000;
    NSLog(@"随机数：%d", randomNumber);
    
    timeSp = [NSString stringWithFormat:@"Meboo%@%d",timeSp,randomNumber];
    
    return timeSp;
}
- (NSString *)get18BirthDayStr {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"]; // 设置日期格式
    //获取18年前的今天
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDate *today = [NSDate date]; // 获取当前日期
    NSDateComponents *components = [[NSDateComponents alloc] init];
    [components setDay:-1];
    components.year = -18; // 将年份减去18
    NSDate *eighteenYearsAgo = [calendar dateByAddingComponents:components toDate:today options:0]; // 计算18年前的日期
    NSString *dateString = [formatter stringFromDate:eighteenYearsAgo];
    
    //    2020-10-11
        NSString *monthStr = [dateString substringFromIndex:5];
        monthStr = [monthStr substringToIndex:2];
        
        NSString *yearStr = [dateString substringToIndex:4];
        NSString *dayStr = [dateString substringFromIndex:8];
        return [NSString stringWithFormat:@"%@/%@/%@",monthStr,dayStr,yearStr];
}


- (NSString *)getWantValue {
    //默认值
    return @"248";
//    NSString *codeStr = @"";
//    for (NSDictionary *dict in [KLUserAccount defaultAccount].userWant) {
//        if ([[NSString stringWithFormat:@"%@",dict[@"select"]] isEqualToString:@"1"]) {
//            codeStr = [NSString stringWithFormat:@"%@",dict[@"code"]];
//            break;
//        }
//    }
//    return codeStr;
}

- (NSMutableArray *)getAcceptValue {
    NSMutableArray *codeArr = [NSMutableArray array];
    for (NSDictionary *dict in [MBUserAccount defaultAccount].youAccept) {
        if ([[NSString stringWithFormat:@"%@",dict[@"select"]] isEqualToString:@"1"]) {
            [codeArr addObject:[NSString stringWithFormat:@"%@",dict[@"code"]]];
        }
    }
    return codeArr;
}


- (void)getLookingForValue {
    NSString *codeStr = @"0";
    if ([[MBUserAccount defaultAccount].gender integerValue] == 1) {
        codeStr = @"2";
    } else if ([[MBUserAccount defaultAccount].gender integerValue] == 2) {
        codeStr = @"1";
    }
    MBUserAccount *account = [MBUserAccount defaultAccount];
    account.aboutMe = @"";
    account.lookingFor = codeStr;
    [MBUserAccount saveAccount:account];
}

@end
